package com.tangsw.springbootdemo.controller;

import com.tangsw.springbootdemo.bo.ResultBO;
import com.tangsw.springbootdemo.bo.TestBO;
import com.tangsw.springbootdemo.model.enums.RenewalStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("/")
public class HelloController {
    @RequestMapping(value = "helloworld", method = {RequestMethod.GET}, produces = {"application/json;charset=UTF-8"})
    public ResultBO<String> helloWorld(@RequestParam(value = "name", required = false, defaultValue = "") String name) {
        return new ResultBO("0000", null, null, String.format("Hi! %s,Hello World!", name));
    }

    @RequestMapping(value = "helloworld2", method = {RequestMethod.GET}, produces = {"application/json;charset=UTF-8"})
    public ResultBO<String> helloWorld2() {
        TestBO testBO = new TestBO();
        BigDecimal bigDecimal = new BigDecimal("666.3334232323");
        testBO.setMoney(bigDecimal);
        return new ResultBO("0000", null, null, testBO);
    }

    @RequestMapping(value = "helloworld3", method = {RequestMethod.POST}, produces = {"application/json;charset=UTF-8"})
    public ResultBO<String> helloWorld3(TestBO testBO) {
        return new ResultBO("0000", null, null, testBO);
    }
}
